<!DOCTYPE html>
<html>

	<head>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black" />
		<meta name="format-detection" content="telephone=no" />
		<meta charset="utf-8">
		<title>签到送积分</title>
		<link rel="stylesheet" href="__TPL__/team/css/ectouch.css" />
	</head>

	<body>
		<div id="loading"><img src="__TPL__/team/images/loading.gif" /></div>

		<div class="con">
			<div class="user-sign-box">
				<section>
					<header class="header position-rel">
						<div class="title padding-all dis-box font-03">
							<a href="javascript:;" class="box-flex j-sign-rule j-show-div "><i class="iconfont icon-gantanhao font-05"></i>签到规则</a>
							<a href="{:url('user/user_sign_detail')}" class="box-flex text-r"><i class="iconfont icon-zichanmingxi font-05"></i>积分明细</a>
						</div>
						<div class="cont position-rel j-sign" onclick='changeText()'>
							<img src="__TPL__/team/images/sign_header.png" class="img">
							<div class="cont-box position-abo text-c w-1">
								{if $is_sign eq '1'}
								<p class="font-08 ec-color" id='boldStuff'>已签到</p>
								{else}
								<p class="font-08 ec-color" id='boldStuff'>签到</p>
								{/if}
								<div class="hr"></div>
								<label class="db col-9 font-01">加{$sign_points}积分</label>
							</div>
						</div>
						<p class="text-c ec-white font-03 m-top06">当前积分</p>
						<h4 class="ec-white text-c font-2-6" id ="pay_points">{$pay_points}</h4>
					</header>

				</section>
				<section class="index-seckill m-top10">
					<div class="box padding-all b-color-f wallet-bt">
						<h3 class="recom-title">
						热门换购
						<span class="t-jiantou ec-conc"><i class="iconfont icon-jiantou position-abo"></i></span>
					</h3>
					</div>


					<ul class="ul-2 user-sign-list b-color-f of-hidden" id="J_ItemList">
						<li class="single_item"></li>
						<a href="javascript:;" style="text-align:center" class="get_more"></a>

					</ul>

				</section>
				<div class="padding-all">
					<a href="{:url('exchange/index')}" class="btn btn-submit b-s">点击查看积分兑换礼品</a>
				</div>
			</div>

		</div>
		<!--签到弹框-->
		<div class="sign-modal maxbox ts-3">
			<div class="modal-header"><img src="__TPL__/team/images/modal_header.png" class="img"></div>
			<div class="modal-close j-modal-close"><img src="__TPL__/team/images/sign-close.png" class="img"></div>
			<div class="sign-bg sign-right-bg"><img src="__TPL__/team/images/sign-bg-2.png" class="img"></div>
			<div class="sign-bg sign-left-bg tf-180"><img src="__TPL__/team/images/sign-bg-2.png" class="img"></div>
			<div class="modal-cont">

				<div class="cont-header">
					<div class="title"><img src="__TPL__/team/images/df.png" class="img"></div>

				</div>
				<h4 class="cont-title col-3 font-05 text-c">签到将获得<em class="ec-tag" id="sign_points">{$sign_points}</em>积分</h4>
				<div class="cont-cont ">

				<style>
				*{margin:0;padding:0;font:14px/1.8 "Helvetica Neue","microsoft yahei";}
				ul,li{list-style:none;}
				body{background: #fff; }
				.title-box{display:none;}
				.checkin{margin: auto auto auto auto; }
				.clear {clear:both; height:0; overflow:hidden; display:block; line-height:0}
				.clearfix:after {clear:both;font-size:0; height:0; display:block; visibility:hidden; content:" "; line-height:0}
				.clearfix {zoom:1;}/* for IE6 IE7 */
				.title-box{height: 36px;line-height: 36px;font-size: 16px;margin-bottom: 10px;}
				.title-box p{float: left;width: 80%;height: 36px;line-height: 36px;font-size: 16px;}
				.title-box a{display: inline-block;width: 20%;height: 36px;line-height: 36px;text-align: center;background: #42941a;border-radius: 5px;color: #fff;text-decoration: none;font-size: 16px;}
				.checkin li{float: left;line-height:35px;text-align: center;}

				li.able-qiandao{background: #e9c530; }
				li.checked{background:url(themes/default/team/images/rili.png) no-repeat center;background-size:50% 50%;}
				.mask{ width: 100%;height: 100%;position: absolute;top: 0;left: 0; background-color: rgba(0,0,0,0.55);visibility: hidden;transition: all 0.25s ease}
				.modal{background:#fff;border-radius: 10px;position: absolute;left: 2rem;right:2rem;top: 20%;box-sizing:border-box;overflow: hidden;transform: translateY(-200%);transition: all 0.25s ease}
				a.closeBtn{display: block;position: absolute;right: 10px;top: 5px;font-family: 'simsun';font-size: 18px;text-decoration: none;font-weight: bolder;color: #333}
				.title_h1{text-align: center;font-size: 40px;font-weight: normal;padding-top:3rem;display: block;width: 100%}
				.title_h1 span{display: block;width: 40px;height: 40px;text-align: center; border-radius: 100%;background: #42941a;color: #fff;position: relative;margin:0 auto;}
				.title_h1 span::before{width: 10px;height: 2px;background: #fff;position: absolute;left: 8px;top: 23px;display: block;line-height: 0;font-size: 0;content: ""; transform: rotate(52deg);}
				.title_h1 span::after{width: 24px;height: 2px;background: #fff;position: absolute;left: 12px;top: 20px;display: block;line-height: 0;font-size: 0;content: "";transform: rotate(-45deg);}
				.title_h1 em{display: block;font-size: 2rem;margin:0 auto;}
				.title_h1 i{display: inline-block;font-size: 16px;float: left;margin: 14px 0 0 10px;}
				.title_h2{text-align: center;font-size: 16px;display: block;padding:0rem 0 3rem 0;}
				.title_h2 span{font-size: 36px;color: #b25d06;}
				.trf{visibility: visible;}
				.trf .modal{transform: translateY(0);}

				</style>
				<script src="http://apps.bdimg.com/libs/jquery/1.10.1/jquery.min.js"></script>
				<div class="checkin">

				</div>
				<div class="mask">
					<div class="modal">
						<a href="#" class="closeBtn">×</a>
						<h1 class="title_h1 clearfix"><span></span><em>已签到成功</em> <!-- <i>您已签到2天</i> --></h1>
						<h2 class="title_h2">您获得<span id="points"></span>积分</h2>
					</div>
				</div>
				<script>
				;
				(function($) {
					var Checkin = function(ele, options) {
						this.ele = ele;
						this.opt = options;
						this.defaults = {
							//width: 452,
							height: 'auto',
							radius: 10,
							color: '#ec5151',
							padding:5,
							dateArray: [{$day}], // 已签到的天数-1
						};
						this.obj = $.extend({}, this.defaults, this.opt);
					}
					Checkin.prototype.init = function() {
						var _self = this.ele,
							html = '',
							myDate = new Date(),
							year = myDate.getFullYear(),
							month = myDate.getMonth(),
							day = myDate.getDate(),
							weekText = ['日', '一', '二', '三', '四', '五', '六'];
						_self.css({
							width: this.obj.width + 'px',
							height: this.obj.height,
							background: this.obj.background,
							borderRadius: this.obj.radius,
							color: this.obj.color,
							padding: this.obj.padding
						}).append("<div class='title-box'><p><em id ='year'>" + year +"</em>" + '年'+"<em id ='month'>" + (month + 1) +"</em>" + '月' + day + '日' + "</em></p></div>");
						$("<ul class='week clearfix'></ul><ul class='calendarList clearfix'></ul>").appendTo(_self);
						for (var i = 0; i < 7; i++) {
							_self.find(".week").append("<li>" + weekText[i] + "</li>")
						};
						for (var i = 0; i < 42; i++) {
							html += "<li></li>"
						};
						_self.find(".calendarList").append(html);
						var $li = _self.find(".calendarList").find("li");
						_self.find(".week li").css({
							width: (_self.width() / 7) + 'px',
							height: 35 + 'px',

							boxSizing: 'border-box',
							background: '#ffe2dd'
						});
						$li.css({
							width: (_self.width() / 7) + 'px',
							height: 35 + 'px',

							boxSizing: 'border-box',
							color: "#333"
						});
						_self.find(".calendarList").find("li:nth-child(7n)").css('borderRight', 'none');
						_self.find(".week li:nth-child(7n)").css('borderRight', 'none');
						var monthFirst = new Date(year, month, 1).getDay();
						var d = new Date(year, (month + 1), 0)
						var totalDay = d.getDate(); //获取当前月的天数
						for (var i = 0; i < totalDay; i++) {
							$li.eq(i + monthFirst).html(i + 1);
							$li.eq(i + monthFirst).addClass('data' + (i + 1))
							if (isArray(this.obj.dateArray)) {
								for (var j = 0; j < this.obj.dateArray.length; j++) {
									if (i == this.obj.dateArray[j]) {
										// 假设已经签到的
										$li.eq(i + monthFirst).addClass('checked');
									}
								}
							}
						}
						//$li.eq(monthFirst+day-1).css('background','#f7ca8e')
						if(_self.find($(".data" + day)).hasClass('checked')){

						}else{
							_self.find($(".data" + day)).addClass('able-qiandao');
						}

					}
					var isChecked = false;
					Checkin.prototype.events = function() {
						var _self = this.ele;
						var $li = _self.find(".calendarList").find("li");
						$li.on('click', function(event) {
							event.preventDefault();
							/* Act on the event */

							if ($(this).hasClass('able-qiandao')) {
								$(this).addClass('checked');
								$(this).removeClass('able-qiandao');
								modal(_self);
								isChecked = true;
								var points = $('#sign_points').html();//赠送积分
								var year = $('#year').html();//年
								var month = $('#month').html();//月
								var day = $(this).html();//当月几号
								$.ajax({
									type: "POST",
									url: "index.php?m=default&c=user&a=add_points",
									data: {points:points,year:year,month:month,day:day},
									dataType:"json",
									success: function(data){
									if (data.error == 1)
									{
										document.getElementById('boldStuff').innerHTML = '已签到';
										document.getElementById('pay_points').innerHTML = data.pay_points;
										document.getElementById('points').innerHTML = data.points;
									}

								}});

							}
						});
						var checkBtn = _self.find(".checkBtn");
						checkBtn.click(function(event) {
							modal(_self);
							_self.find('.able-qiandao').addClass('checked');
							isChecked = true;
						});
					}
					var modal = function(e) {
						var mask = e.parents().find(".mask");
						var close = e.parents().find(".closeBtn");
						if (mask && !isChecked) {
							mask.addClass('trf');
						} else {
							return
						};
						close.click(function(event) {
							event.preventDefault();
							mask.removeClass('trf')
						});
						e.parents().find('.checkBtn').text("已签到");
					}
					$.fn.Checkin = function(options) {
						var checkin = new Checkin(this, options);
						var obj = [checkin.init(), checkin.events()]
						return obj
					}
					var isArray = function(arg) {
						return Object.prototype.toString.call(arg) === '[object Array]';
					};
				})(jQuery);
				// 插件调用
				$(".checkin").Checkin();
				// 元素居中显示，与插件无关，根本自己需要修改；
				//$(".checkin").css('marginTop',50+'px');
				</script>



				<!-- <img src="__TPL__/team/images/rili.jpg" class="img"> -->

				</div>
				<div class="padding-all">
					<a href="{:url('exchange/index')}" class="btn btn-submit b-s">点击查看积分兑换商品</a>
				</div>
			</div>
		</div>
		<div class="sign-modal-bg ts-3"></div>

		<!--签到规则-->
		<div class="user-sign-rule maxbox">
			<h4 class="font-07 col-5 padding-all wallet-bt">签到规则<i class="iconfont icon-guanbi j-close-rule font-03 col-7 font-05 icon-guanbi show-div-guanbi fr"></i></h4>
			<div class="sign-max-height padding-all">
				<p class="col-6 font-03">1.每天签到北京等你吧你的比你牛逼你补兵你补兵那发你不发那边呢你不方便呢方柏霓 不能内部那边能不能把你发不发报复办法吧你方便能发你不发呢办公你你，报告发布会</p>
				<p class="col-6 font-03">2.签到北京等你吧你的比你牛逼你补兵你补兵那发你不发那边呢你不方便呢方柏霓 不能内部那边能不能把你发不发报复办法吧你方便能发你不发呢办公你你，报告发布会</p>
				<p class="col-6 font-03">3.每天签到北京等你吧你的比你牛逼你补兵你补兵那发你不发那边呢你不方便呢方柏霓 不能内部那边能不能把你发不发报复办法吧你方便能发你不发呢办公你你，报告发布会</p>
				<p class="col-6 font-03">4.签到北京等你吧你的比你牛逼你补兵你补兵那发你不发那边呢你不方便呢方柏霓 不能内部那边能不能把你发不发报复办法吧你方便能发你不发呢办公你你，报告发布会</p>

			</div>
		</div>

		<!--引用js-->
		<script type="text/javascript" src="__TPL__/team/js/jquery-2.1.4.min.js"></script>
		<script type="text/javascript" src="__TPL__/team/js/swiper.min.js"></script>
		<script type="text/javascript" src="__TPL__/team/js/ectouch.js"></script>

		<!--异步加载-->
		<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
		<script type="text/javascript" src="__PUBLIC__/js/jquery.more.js"></script>
		<script type="text/javascript" >var tpl = '__TPL__';</script>
		<script type="text/javascript">
			get_asynclist("{:url('user/sing_goods', array('type'=>'is_hot'))}", '__TPL__/images/loader.gif');
		</script>
	</body>
	<script type="text/javascript">
		/*function changeText() {
			document.getElementById('boldStuff').innerHTML = '已签到';
		}*/
	</script>

</html>